package ht6_huffman;


/**
 * ArbolBinario
 * @author Jorge Lainfiesta 11142
 * @since Sep 17, 2012
 * @version 1
 */
public class ArbolBinario<E>{

    protected E data;
    private ArbolBinario<E> right;
    private ArbolBinario<E> left;
    private ArbolBinario<E> parent;
    
    
    /**
     * Constructor
     * @param caracter que compone el arbol
     */
    public ArbolBinario(E data){
        this.data = data;
    }
    
    public ArbolBinario(){
        
    }

    /**
     * @return the data
     */
    public E getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(E data) {
        this.data = data;
    }

    /**
     * @return the right
     */
    public ArbolBinario<E> getRight() {
        return right;
    }

    /**
     * @param right the right to set
     */
    public void setRight(ArbolBinario<E> right) {
        if (this.right != null && this.right.getParent() == this)
            this.right.setParent(null);
        this.right = right;
        this.right.setParent(this);
    }

    /**
     * @return the left
     */
    public ArbolBinario<E> getLeft() {
        return left;
    }

    /**
     * @param left the left to set
     */
    public void setLeft(ArbolBinario<E> left) {
        if (this.left != null && this.left.getParent() == this)
            this.left.setParent(null);
        this.left = left;
        this.left.setParent(this);
    }

    /**
     * @return the parent
     */
    public ArbolBinario<E> getParent() {
        return parent;
    }

    /**
     * @param parent the parent to set
     */
    public void setParent(ArbolBinario<E> parent) {
        this.parent = parent;
    }


}
